<?php

namespace App\Providers;

use App\Business\DataLog\DataBase;
use App\Business\DataLog\DataBaseStatic;
use App\Extend\Test;
use App\Jobs\LogQueue;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\DB;
use Symfony\Component\VarDumper\Cloner\Data;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {


         DB::listen(function ($query) {

            $conntionName=$query->connectionName;

             $q=new \stdClass();
             $q->sql=$query->sql;
             $q->bindings=$query->bindings;

            if(strpos(strtolower ($conntionName),"log")===false) {
                DataBaseStatic::AddSQL($q);
                /*$log=new DataBase();
                $log->query=$q;
                dispatch(new LogQueue($log));*/
            }

            // $query->sql
            // $query->bindings
            // $query->time
        });


    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}
